﻿using System;
using Gean;
using Gean.Wrapper;
using Pansoft.Authority.Entities;
using Pansoft.HIME.Base.Enums;
using Pansoft.HIME.Base.ViewModels;

namespace Pansoft.HIME.Controllers.Api
{
#if DEBUG

    internal static class Mocks
    {
        private static readonly UtilityRandom _Rand = new UtilityRandom();

        public static StaffProfile GetDemoStaffProfile(string orgid, string staffid, string pwd)
        {
            var staff = new StaffProfile
            {
                Id = staffid,
                Name = "张绣花",
                OrganizationId = orgid,
                OrganizationName = "将台路营业厅",
                RoleId = string.Format("Auth{0}", _Rand.Next(100, 399)),
                LastLoginTime = DateTime.Now,
                LoginStatus = 1
            };
            return staff;
        }

        public static StaffViewModel[] GetDemoStaffArray(string orgId)
        {
            var n = _Rand.Next(8, 24);
            var array = new StaffViewModel[n];
            for (int i = 0; i < n; i++)
            {
                array[i] = GetDemoStaff(i, orgId);
            }
            return array;
        }

        public static StaffViewModel GetDemoStaff(int n, string orgId)
        {
            var staffvm = new StaffViewModel
            {
                Id = string.Format("{0}-{1}-{2}", Guid.NewGuid().ToString().Substring(0, 3), n, orgId).ToUpper(),
                Name = string.Format("姓名{0}", n),
                Sex = (PersonSex) (_Rand.Next(0, 4) - 1),
                CreatedTime = new DateTime(_Rand.Next(1996, 2012), _Rand.Next(1, 12), _Rand.Next(1, 25)),
                ModifiedTime = new DateTime(_Rand.Next(1996, 2012), _Rand.Next(1, 12), _Rand.Next(1, 25)),
                LoginDateTime = new DateTime(_Rand.Next(1996, 2012), _Rand.Next(1, 12), _Rand.Next(1, 25)),
                Email = _Rand.GetString(_Rand.Next(4, 10), UtilityRandom.RandomCharType.Lowercased) + "@p-an.com",
                MobilePhone = string.Format("13{0}", _Rand.Next(112341234, 912341234)),
                LoginCounterId = _Rand.Next(0, 12)
            };
            return staffvm;
        }

        public static OrganizationViewModel GetDemoOrganizationViewModel(int id, int pId)
        {
            var orgVm = new OrganizationViewModel();
            orgVm.id = string.Format("ORG-{0}", id.ToString().PadLeft(3, '0')).ToUpper();
            orgVm.name = string.Format("组织名称{0}", pId.ToString().PadLeft(3, '0'));
            orgVm.category = OrganizationCategory.Item;
            return orgVm;
        }

#endif
    }
}